//
//  THCountdownManager.h
//  MengLiao
//
//  Created by xiuxin on 2022/7/14.
//  Copyright © 2022 BaseBusiness. All rights reserved.
//

#import <Foundation/Foundation.h>

NS_ASSUME_NONNULL_BEGIN

typedef void(^THCountdownManagerBlock)(NSTimeInterval remainingTime);

@interface THCountdownManager : NSObject

@property (nonatomic, copy) NSString *countDownName;//定时器名称(用于却别定时器)
@property (nonatomic, copy,nullable) THCountdownManagerBlock countDownActive;
@property (nonatomic, copy,nullable) THCountdownManagerBlock countDownStarted;
@property (nonatomic, copy,nullable) THCountdownManagerBlock countDownEnded;

/**
 创建定时器
 @param delayTime 结束延迟
 @param countDownActive 每秒做什么
 @return THCountdownManager
 */

+ (THCountdownManager *)startCountdownTimerWithDelayTime:(NSTimeInterval)delayTime countDownActive:(nullable THCountdownManagerBlock )countDownActive;

/**
 创建定时器
 @param finishTimeInterval 结束时间戳
 @param countDownActive 每秒做什么
 @return THCountdownManager
 */
+ (THCountdownManager *)startCountdownTimerWithFinishTimeInterval:(NSTimeInterval)finishTimeInterval countDownActive:(nullable THCountdownManagerBlock)countDownActive;


- (void)resetActiveTimeInterval:(NSTimeInterval )activeTimeInterval;

/**
 开启定时器
 @param timerInterval 结束时间戳
 */
- (void)startCountDownWithTimerInterval:(NSTimeInterval )timerInterval;

///  开启定时器
/// @param delayTime delayTime 结束时间间隔
- (void)startCountDownWithDelayTime:(NSTimeInterval )delayTime;

/**
 结束时间为LONG_MAX
 */
- (void)startCountDown;

/**
 关闭定时器
 */
- (void)stopCountDown;

/**
 刷新定时器
 @param timerInterval 结束时间戳
 */
- (void)refreshTimerWithTimerInterval:(NSTimeInterval )timerInterval;

/**
 刷新定时器
 @param delayTime 间隔结束时间(距调用此方法时 多久之后)
 */
- (void)refreshTimerWithDelayTime:(NSTimeInterval )delayTime;



/// 定时器是否正在执行
- (BOOL)isRunning;

@end

NS_ASSUME_NONNULL_END
